
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 2016/11/4 9:05:18
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace yncTech.BusinessObjects
{
	/// <summary>
	/// Encapsulates the 'Fin_Box' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(FinBox))]	
	[XmlType("FinBox")]
	public partial class FinBox : esFinBox
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new FinBox();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Decimal boxID)
		{
			var obj = new FinBox();
			obj.BoxID = boxID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Decimal boxID, esSqlAccessType sqlAccessType)
		{
			var obj = new FinBox();
			obj.BoxID = boxID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("FinBoxCollection")]
	public partial class FinBoxCollection : esFinBoxCollection, IEnumerable<FinBox>
	{
		public FinBox FindByPrimaryKey(System.Decimal boxID)
		{
			return this.SingleOrDefault(e => e.BoxID == boxID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(FinBox))]
		public class FinBoxCollectionWCFPacket : esCollectionWCFPacket<FinBoxCollection>
		{
			public static implicit operator FinBoxCollection(FinBoxCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator FinBoxCollectionWCFPacket(FinBoxCollection collection)
			{
				return new FinBoxCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class FinBoxQuery : esFinBoxQuery
	{
        public FinBoxQuery() : this("FinBoxQuery")
		{
		}
		public FinBoxQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "FinBoxQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(FinBoxQuery query)
		{
			return FinBoxQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator FinBoxQuery(string query)
		{
			return (FinBoxQuery)FinBoxQuery.SerializeHelper.FromXml(query, typeof(FinBoxQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esFinBox : esEntity
	{
		public esFinBox()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Decimal boxID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(boxID);
			else
				return LoadByPrimaryKeyStoredProcedure(boxID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Decimal boxID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(boxID);
			else
				return LoadByPrimaryKeyStoredProcedure(boxID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Decimal boxID)
		{
			FinBoxQuery query = new FinBoxQuery();
			query.Where(query.BoxID == boxID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Decimal boxID)
		{
			esParameters parms = new esParameters();
			parms.Add("BoxID", boxID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to Fin_Box.BoxID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? BoxID
		{
			get
			{
				return base.GetSystemDecimal(FinBoxMetadata.ColumnNames.BoxID);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinBoxMetadata.ColumnNames.BoxID, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxLocation
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? BoxLocation
		{
			get
			{
				return base.GetSystemDecimal(FinBoxMetadata.ColumnNames.BoxLocation);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinBoxMetadata.ColumnNames.BoxLocation, value))
				{
					this._UpToBFThirdUnitByBoxLocation = null;
					this.OnPropertyChanged("UpToBFThirdUnitByBoxLocation");
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxLocation);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxNo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String BoxNo
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.BoxNo);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.BoxNo, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxNo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.DocumentType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String DocumentType
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.DocumentType);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.DocumentType, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.DocumentType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.FunctionDept
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String FunctionDept
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.FunctionDept);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.FunctionDept, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.FunctionDept);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxYear
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? BoxYear
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.BoxYear);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.BoxYear, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxYear);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxMonth
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? BoxMonth
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.BoxMonth);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.BoxMonth, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxMonth);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxYearEnd
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? BoxYearEnd
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.BoxYearEnd);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.BoxYearEnd, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxYearEnd);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxMonthEnd
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? BoxMonthEnd
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.BoxMonthEnd);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.BoxMonthEnd, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxMonthEnd);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.BoxIndex
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? BoxIndex
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.BoxIndex);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.BoxIndex, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxIndex);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.StorageStatus
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String StorageStatus
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.StorageStatus);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.StorageStatus, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.StorageStatus);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.SupplierBoxNo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String SupplierBoxNo
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.SupplierBoxNo);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.SupplierBoxNo, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.SupplierBoxNo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IsOpen_na
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsOpenNa
		{
			get
			{
				return base.GetSystemBoolean(FinBoxMetadata.ColumnNames.IsOpenNa);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinBoxMetadata.ColumnNames.IsOpenNa, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IsOpenNa);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.NoSapReceiptCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? NoSapReceiptCount
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.NoSapReceiptCount);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.NoSapReceiptCount, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.NoSapReceiptCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.CreatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CreatedBy
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.CreatedBy);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.CreatedBy, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.CreatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.CreatedDttm
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? CreatedDttm
		{
			get
			{
				return base.GetSystemDateTime(FinBoxMetadata.ColumnNames.CreatedDttm);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinBoxMetadata.ColumnNames.CreatedDttm, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.CreatedDttm);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.UpdatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String UpdatedBy
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.UpdatedBy);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.UpdatedBy, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.UpdatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.UpdatedDttm
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? UpdatedDttm
		{
			get
			{
				return base.GetSystemDateTime(FinBoxMetadata.ColumnNames.UpdatedDttm);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinBoxMetadata.ColumnNames.UpdatedDttm, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.UpdatedDttm);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.VersionNo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? VersionNo
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.VersionNo);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.VersionNo, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.VersionNo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.CompanyName
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CompanyName
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.CompanyName);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.CompanyName, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.CompanyName);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.CompanyCode
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CompanyCode
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.CompanyCode);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.CompanyCode, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.CompanyCode);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IsDeleted
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsDeleted
		{
			get
			{
				return base.GetSystemBoolean(FinBoxMetadata.ColumnNames.IsDeleted);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinBoxMetadata.ColumnNames.IsDeleted, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IsDeleted);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.ThirdUnitCabinId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Guid? ThirdUnitCabinId
		{
			get
			{
				return base.GetSystemGuid(FinBoxMetadata.ColumnNames.ThirdUnitCabinId);
			}
			
			set
			{
				if(base.SetSystemGuid(FinBoxMetadata.ColumnNames.ThirdUnitCabinId, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.ThirdUnitCabinId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.ThirdUnitNumberId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Guid? ThirdUnitNumberId
		{
			get
			{
				return base.GetSystemGuid(FinBoxMetadata.ColumnNames.ThirdUnitNumberId);
			}
			
			set
			{
				if(base.SetSystemGuid(FinBoxMetadata.ColumnNames.ThirdUnitNumberId, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.ThirdUnitNumberId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IsSap
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsSap
		{
			get
			{
				return base.GetSystemBoolean(FinBoxMetadata.ColumnNames.IsSap);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinBoxMetadata.ColumnNames.IsSap, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IsSap);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IsHis
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsHis
		{
			get
			{
				return base.GetSystemBoolean(FinBoxMetadata.ColumnNames.IsHis);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinBoxMetadata.ColumnNames.IsHis, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IsHis);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.NeedStoreYear
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? NeedStoreYear
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.NeedStoreYear);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.NeedStoreYear, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.NeedStoreYear);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IsUpdating
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsUpdating
		{
			get
			{
				return base.GetSystemBoolean(FinBoxMetadata.ColumnNames.IsUpdating);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinBoxMetadata.ColumnNames.IsUpdating, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IsUpdating);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IndexStart
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String IndexStart
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.IndexStart);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.IndexStart, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IndexStart);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IndexEnd
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String IndexEnd
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.IndexEnd);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.IndexEnd, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IndexEnd);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.IndexType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? IndexType
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.IndexType);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.IndexType, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.IndexType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.DeleteReason
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String DeleteReason
		{
			get
			{
				return base.GetSystemString(FinBoxMetadata.ColumnNames.DeleteReason);
			}
			
			set
			{
				if(base.SetSystemString(FinBoxMetadata.ColumnNames.DeleteReason, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.DeleteReason);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_Box.DeleteReceiptCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? DeleteReceiptCount
		{
			get
			{
				return base.GetSystemInt32(FinBoxMetadata.ColumnNames.DeleteReceiptCount);
			}
			
			set
			{
				if(base.SetSystemInt32(FinBoxMetadata.ColumnNames.DeleteReceiptCount, value))
				{
					OnPropertyChanged(FinBoxMetadata.PropertyNames.DeleteReceiptCount);
				}
			}
		}		
		
		[CLSCompliant(false)]
		internal protected BFThirdUnit _UpToBFThirdUnitByBoxLocation;
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "BoxID": this.str().BoxID = (string)value; break;							
						case "BoxLocation": this.str().BoxLocation = (string)value; break;							
						case "BoxNo": this.str().BoxNo = (string)value; break;							
						case "DocumentType": this.str().DocumentType = (string)value; break;							
						case "FunctionDept": this.str().FunctionDept = (string)value; break;							
						case "BoxYear": this.str().BoxYear = (string)value; break;							
						case "BoxMonth": this.str().BoxMonth = (string)value; break;							
						case "BoxYearEnd": this.str().BoxYearEnd = (string)value; break;							
						case "BoxMonthEnd": this.str().BoxMonthEnd = (string)value; break;							
						case "BoxIndex": this.str().BoxIndex = (string)value; break;							
						case "StorageStatus": this.str().StorageStatus = (string)value; break;							
						case "SupplierBoxNo": this.str().SupplierBoxNo = (string)value; break;							
						case "IsOpenNa": this.str().IsOpenNa = (string)value; break;							
						case "NoSapReceiptCount": this.str().NoSapReceiptCount = (string)value; break;							
						case "CreatedBy": this.str().CreatedBy = (string)value; break;							
						case "CreatedDttm": this.str().CreatedDttm = (string)value; break;							
						case "UpdatedBy": this.str().UpdatedBy = (string)value; break;							
						case "UpdatedDttm": this.str().UpdatedDttm = (string)value; break;							
						case "VersionNo": this.str().VersionNo = (string)value; break;							
						case "CompanyName": this.str().CompanyName = (string)value; break;							
						case "CompanyCode": this.str().CompanyCode = (string)value; break;							
						case "IsDeleted": this.str().IsDeleted = (string)value; break;							
						case "ThirdUnitCabinId": this.str().ThirdUnitCabinId = (string)value; break;							
						case "ThirdUnitNumberId": this.str().ThirdUnitNumberId = (string)value; break;							
						case "IsSap": this.str().IsSap = (string)value; break;							
						case "IsHis": this.str().IsHis = (string)value; break;							
						case "NeedStoreYear": this.str().NeedStoreYear = (string)value; break;							
						case "IsUpdating": this.str().IsUpdating = (string)value; break;							
						case "IndexStart": this.str().IndexStart = (string)value; break;							
						case "IndexEnd": this.str().IndexEnd = (string)value; break;							
						case "IndexType": this.str().IndexType = (string)value; break;							
						case "DeleteReason": this.str().DeleteReason = (string)value; break;							
						case "DeleteReceiptCount": this.str().DeleteReceiptCount = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "BoxID":
						
							if (value == null || value is System.Decimal)
								this.BoxID = (System.Decimal?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxID);
							break;
						
						case "BoxLocation":
						
							if (value == null || value is System.Decimal)
								this.BoxLocation = (System.Decimal?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxLocation);
							break;
						
						case "BoxYear":
						
							if (value == null || value is System.Int32)
								this.BoxYear = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxYear);
							break;
						
						case "BoxMonth":
						
							if (value == null || value is System.Int32)
								this.BoxMonth = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxMonth);
							break;
						
						case "BoxYearEnd":
						
							if (value == null || value is System.Int32)
								this.BoxYearEnd = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxYearEnd);
							break;
						
						case "BoxMonthEnd":
						
							if (value == null || value is System.Int32)
								this.BoxMonthEnd = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxMonthEnd);
							break;
						
						case "BoxIndex":
						
							if (value == null || value is System.Int32)
								this.BoxIndex = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.BoxIndex);
							break;
						
						case "IsOpenNa":
						
							if (value == null || value is System.Boolean)
								this.IsOpenNa = (System.Boolean?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IsOpenNa);
							break;
						
						case "NoSapReceiptCount":
						
							if (value == null || value is System.Int32)
								this.NoSapReceiptCount = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.NoSapReceiptCount);
							break;
						
						case "CreatedDttm":
						
							if (value == null || value is System.DateTime)
								this.CreatedDttm = (System.DateTime?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.CreatedDttm);
							break;
						
						case "UpdatedDttm":
						
							if (value == null || value is System.DateTime)
								this.UpdatedDttm = (System.DateTime?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.UpdatedDttm);
							break;
						
						case "VersionNo":
						
							if (value == null || value is System.Int32)
								this.VersionNo = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.VersionNo);
							break;
						
						case "IsDeleted":
						
							if (value == null || value is System.Boolean)
								this.IsDeleted = (System.Boolean?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IsDeleted);
							break;
						
						case "ThirdUnitCabinId":
						
							if (value == null || value is System.Guid)
								this.ThirdUnitCabinId = (System.Guid?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.ThirdUnitCabinId);
							break;
						
						case "ThirdUnitNumberId":
						
							if (value == null || value is System.Guid)
								this.ThirdUnitNumberId = (System.Guid?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.ThirdUnitNumberId);
							break;
						
						case "IsSap":
						
							if (value == null || value is System.Boolean)
								this.IsSap = (System.Boolean?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IsSap);
							break;
						
						case "IsHis":
						
							if (value == null || value is System.Boolean)
								this.IsHis = (System.Boolean?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IsHis);
							break;
						
						case "NeedStoreYear":
						
							if (value == null || value is System.Int32)
								this.NeedStoreYear = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.NeedStoreYear);
							break;
						
						case "IsUpdating":
						
							if (value == null || value is System.Boolean)
								this.IsUpdating = (System.Boolean?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IsUpdating);
							break;
						
						case "IndexType":
						
							if (value == null || value is System.Int32)
								this.IndexType = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.IndexType);
							break;
						
						case "DeleteReceiptCount":
						
							if (value == null || value is System.Int32)
								this.DeleteReceiptCount = (System.Int32?)value;
								OnPropertyChanged(FinBoxMetadata.PropertyNames.DeleteReceiptCount);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esFinBox entity)
			{
				this.entity = entity;
			}
			
	
			public System.String BoxID
			{
				get
				{
					System.Decimal? data = entity.BoxID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxID = null;
					else entity.BoxID = Convert.ToDecimal(value);
				}
			}
				
			public System.String BoxLocation
			{
				get
				{
					System.Decimal? data = entity.BoxLocation;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxLocation = null;
					else entity.BoxLocation = Convert.ToDecimal(value);
				}
			}
				
			public System.String BoxNo
			{
				get
				{
					System.String data = entity.BoxNo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxNo = null;
					else entity.BoxNo = Convert.ToString(value);
				}
			}
				
			public System.String DocumentType
			{
				get
				{
					System.String data = entity.DocumentType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DocumentType = null;
					else entity.DocumentType = Convert.ToString(value);
				}
			}
				
			public System.String FunctionDept
			{
				get
				{
					System.String data = entity.FunctionDept;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FunctionDept = null;
					else entity.FunctionDept = Convert.ToString(value);
				}
			}
				
			public System.String BoxYear
			{
				get
				{
					System.Int32? data = entity.BoxYear;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxYear = null;
					else entity.BoxYear = Convert.ToInt32(value);
				}
			}
				
			public System.String BoxMonth
			{
				get
				{
					System.Int32? data = entity.BoxMonth;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxMonth = null;
					else entity.BoxMonth = Convert.ToInt32(value);
				}
			}
				
			public System.String BoxYearEnd
			{
				get
				{
					System.Int32? data = entity.BoxYearEnd;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxYearEnd = null;
					else entity.BoxYearEnd = Convert.ToInt32(value);
				}
			}
				
			public System.String BoxMonthEnd
			{
				get
				{
					System.Int32? data = entity.BoxMonthEnd;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxMonthEnd = null;
					else entity.BoxMonthEnd = Convert.ToInt32(value);
				}
			}
				
			public System.String BoxIndex
			{
				get
				{
					System.Int32? data = entity.BoxIndex;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.BoxIndex = null;
					else entity.BoxIndex = Convert.ToInt32(value);
				}
			}
				
			public System.String StorageStatus
			{
				get
				{
					System.String data = entity.StorageStatus;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.StorageStatus = null;
					else entity.StorageStatus = Convert.ToString(value);
				}
			}
				
			public System.String SupplierBoxNo
			{
				get
				{
					System.String data = entity.SupplierBoxNo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.SupplierBoxNo = null;
					else entity.SupplierBoxNo = Convert.ToString(value);
				}
			}
				
			public System.String IsOpenNa
			{
				get
				{
					System.Boolean? data = entity.IsOpenNa;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsOpenNa = null;
					else entity.IsOpenNa = Convert.ToBoolean(value);
				}
			}
				
			public System.String NoSapReceiptCount
			{
				get
				{
					System.Int32? data = entity.NoSapReceiptCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.NoSapReceiptCount = null;
					else entity.NoSapReceiptCount = Convert.ToInt32(value);
				}
			}
				
			public System.String CreatedBy
			{
				get
				{
					System.String data = entity.CreatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedBy = null;
					else entity.CreatedBy = Convert.ToString(value);
				}
			}
				
			public System.String CreatedDttm
			{
				get
				{
					System.DateTime? data = entity.CreatedDttm;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedDttm = null;
					else entity.CreatedDttm = Convert.ToDateTime(value);
				}
			}
				
			public System.String UpdatedBy
			{
				get
				{
					System.String data = entity.UpdatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UpdatedBy = null;
					else entity.UpdatedBy = Convert.ToString(value);
				}
			}
				
			public System.String UpdatedDttm
			{
				get
				{
					System.DateTime? data = entity.UpdatedDttm;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UpdatedDttm = null;
					else entity.UpdatedDttm = Convert.ToDateTime(value);
				}
			}
				
			public System.String VersionNo
			{
				get
				{
					System.Int32? data = entity.VersionNo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.VersionNo = null;
					else entity.VersionNo = Convert.ToInt32(value);
				}
			}
				
			public System.String CompanyName
			{
				get
				{
					System.String data = entity.CompanyName;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CompanyName = null;
					else entity.CompanyName = Convert.ToString(value);
				}
			}
				
			public System.String CompanyCode
			{
				get
				{
					System.String data = entity.CompanyCode;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CompanyCode = null;
					else entity.CompanyCode = Convert.ToString(value);
				}
			}
				
			public System.String IsDeleted
			{
				get
				{
					System.Boolean? data = entity.IsDeleted;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsDeleted = null;
					else entity.IsDeleted = Convert.ToBoolean(value);
				}
			}
				
			public System.String ThirdUnitCabinId
			{
				get
				{
					System.Guid? data = entity.ThirdUnitCabinId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ThirdUnitCabinId = null;
					else entity.ThirdUnitCabinId = new Guid(value);
				}
			}
				
			public System.String ThirdUnitNumberId
			{
				get
				{
					System.Guid? data = entity.ThirdUnitNumberId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ThirdUnitNumberId = null;
					else entity.ThirdUnitNumberId = new Guid(value);
				}
			}
				
			public System.String IsSap
			{
				get
				{
					System.Boolean? data = entity.IsSap;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsSap = null;
					else entity.IsSap = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsHis
			{
				get
				{
					System.Boolean? data = entity.IsHis;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsHis = null;
					else entity.IsHis = Convert.ToBoolean(value);
				}
			}
				
			public System.String NeedStoreYear
			{
				get
				{
					System.Int32? data = entity.NeedStoreYear;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.NeedStoreYear = null;
					else entity.NeedStoreYear = Convert.ToInt32(value);
				}
			}
				
			public System.String IsUpdating
			{
				get
				{
					System.Boolean? data = entity.IsUpdating;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsUpdating = null;
					else entity.IsUpdating = Convert.ToBoolean(value);
				}
			}
				
			public System.String IndexStart
			{
				get
				{
					System.String data = entity.IndexStart;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IndexStart = null;
					else entity.IndexStart = Convert.ToString(value);
				}
			}
				
			public System.String IndexEnd
			{
				get
				{
					System.String data = entity.IndexEnd;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IndexEnd = null;
					else entity.IndexEnd = Convert.ToString(value);
				}
			}
				
			public System.String IndexType
			{
				get
				{
					System.Int32? data = entity.IndexType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IndexType = null;
					else entity.IndexType = Convert.ToInt32(value);
				}
			}
				
			public System.String DeleteReason
			{
				get
				{
					System.String data = entity.DeleteReason;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DeleteReason = null;
					else entity.DeleteReason = Convert.ToString(value);
				}
			}
				
			public System.String DeleteReceiptCount
			{
				get
				{
					System.Int32? data = entity.DeleteReceiptCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DeleteReceiptCount = null;
					else entity.DeleteReceiptCount = Convert.ToInt32(value);
				}
			}
			

			private esFinBox entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return FinBoxMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public FinBoxQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinBoxQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinBoxQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(FinBoxQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private FinBoxQuery query;		
	}



	[Serializable]
	abstract public partial class esFinBoxCollection : esEntityCollection<FinBox>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return FinBoxMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "FinBoxCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public FinBoxQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinBoxQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinBoxQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new FinBoxQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(FinBoxQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((FinBoxQuery)query);
		}

		#endregion
		
		private FinBoxQuery query;
	}



	[Serializable]
	abstract public partial class esFinBoxQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return FinBoxMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "BoxID": return this.BoxID;
				case "BoxLocation": return this.BoxLocation;
				case "BoxNo": return this.BoxNo;
				case "DocumentType": return this.DocumentType;
				case "FunctionDept": return this.FunctionDept;
				case "BoxYear": return this.BoxYear;
				case "BoxMonth": return this.BoxMonth;
				case "BoxYearEnd": return this.BoxYearEnd;
				case "BoxMonthEnd": return this.BoxMonthEnd;
				case "BoxIndex": return this.BoxIndex;
				case "StorageStatus": return this.StorageStatus;
				case "SupplierBoxNo": return this.SupplierBoxNo;
				case "IsOpenNa": return this.IsOpenNa;
				case "NoSapReceiptCount": return this.NoSapReceiptCount;
				case "CreatedBy": return this.CreatedBy;
				case "CreatedDttm": return this.CreatedDttm;
				case "UpdatedBy": return this.UpdatedBy;
				case "UpdatedDttm": return this.UpdatedDttm;
				case "VersionNo": return this.VersionNo;
				case "CompanyName": return this.CompanyName;
				case "CompanyCode": return this.CompanyCode;
				case "IsDeleted": return this.IsDeleted;
				case "ThirdUnitCabinId": return this.ThirdUnitCabinId;
				case "ThirdUnitNumberId": return this.ThirdUnitNumberId;
				case "IsSap": return this.IsSap;
				case "IsHis": return this.IsHis;
				case "NeedStoreYear": return this.NeedStoreYear;
				case "IsUpdating": return this.IsUpdating;
				case "IndexStart": return this.IndexStart;
				case "IndexEnd": return this.IndexEnd;
				case "IndexType": return this.IndexType;
				case "DeleteReason": return this.DeleteReason;
				case "DeleteReceiptCount": return this.DeleteReceiptCount;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem BoxID
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxID, esSystemType.Decimal); }
		} 
		
		public esQueryItem BoxLocation
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxLocation, esSystemType.Decimal); }
		} 
		
		public esQueryItem BoxNo
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxNo, esSystemType.String); }
		} 
		
		public esQueryItem DocumentType
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.DocumentType, esSystemType.String); }
		} 
		
		public esQueryItem FunctionDept
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.FunctionDept, esSystemType.String); }
		} 
		
		public esQueryItem BoxYear
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxYear, esSystemType.Int32); }
		} 
		
		public esQueryItem BoxMonth
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxMonth, esSystemType.Int32); }
		} 
		
		public esQueryItem BoxYearEnd
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxYearEnd, esSystemType.Int32); }
		} 
		
		public esQueryItem BoxMonthEnd
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxMonthEnd, esSystemType.Int32); }
		} 
		
		public esQueryItem BoxIndex
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.BoxIndex, esSystemType.Int32); }
		} 
		
		public esQueryItem StorageStatus
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.StorageStatus, esSystemType.String); }
		} 
		
		public esQueryItem SupplierBoxNo
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.SupplierBoxNo, esSystemType.String); }
		} 
		
		public esQueryItem IsOpenNa
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IsOpenNa, esSystemType.Boolean); }
		} 
		
		public esQueryItem NoSapReceiptCount
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.NoSapReceiptCount, esSystemType.Int32); }
		} 
		
		public esQueryItem CreatedBy
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.CreatedBy, esSystemType.String); }
		} 
		
		public esQueryItem CreatedDttm
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.CreatedDttm, esSystemType.DateTime); }
		} 
		
		public esQueryItem UpdatedBy
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.UpdatedBy, esSystemType.String); }
		} 
		
		public esQueryItem UpdatedDttm
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.UpdatedDttm, esSystemType.DateTime); }
		} 
		
		public esQueryItem VersionNo
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.VersionNo, esSystemType.Int32); }
		} 
		
		public esQueryItem CompanyName
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.CompanyName, esSystemType.String); }
		} 
		
		public esQueryItem CompanyCode
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.CompanyCode, esSystemType.String); }
		} 
		
		public esQueryItem IsDeleted
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IsDeleted, esSystemType.Boolean); }
		} 
		
		public esQueryItem ThirdUnitCabinId
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.ThirdUnitCabinId, esSystemType.Guid); }
		} 
		
		public esQueryItem ThirdUnitNumberId
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.ThirdUnitNumberId, esSystemType.Guid); }
		} 
		
		public esQueryItem IsSap
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IsSap, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsHis
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IsHis, esSystemType.Boolean); }
		} 
		
		public esQueryItem NeedStoreYear
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.NeedStoreYear, esSystemType.Int32); }
		} 
		
		public esQueryItem IsUpdating
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IsUpdating, esSystemType.Boolean); }
		} 
		
		public esQueryItem IndexStart
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IndexStart, esSystemType.String); }
		} 
		
		public esQueryItem IndexEnd
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IndexEnd, esSystemType.String); }
		} 
		
		public esQueryItem IndexType
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.IndexType, esSystemType.Int32); }
		} 
		
		public esQueryItem DeleteReason
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.DeleteReason, esSystemType.String); }
		} 
		
		public esQueryItem DeleteReceiptCount
		{
			get { return new esQueryItem(this, FinBoxMetadata.ColumnNames.DeleteReceiptCount, esSystemType.Int32); }
		} 
		
		#endregion
		
	}


	
	public partial class FinBox : esFinBox
	{

		#region FinBoxReceiptsCollectionByBoxID - Zero To Many
		
		static public esPrefetchMap Prefetch_FinBoxReceiptsCollectionByBoxID
		{
			get
			{
				esPrefetchMap map = new esPrefetchMap();
				map.PrefetchDelegate = yncTech.BusinessObjects.FinBox.FinBoxReceiptsCollectionByBoxID_Delegate;
				map.PropertyName = "FinBoxReceiptsCollectionByBoxID";
				map.MyColumnName = "BoxID";
				map.ParentColumnName = "BoxID";
				map.IsMultiPartKey = false;
				return map;
			}
		}		
		
		static private void FinBoxReceiptsCollectionByBoxID_Delegate(esPrefetchParameters data)
		{
			FinBoxQuery parent = new FinBoxQuery(data.NextAlias());

			FinBoxReceiptsQuery me = data.You != null ? data.You as FinBoxReceiptsQuery : new FinBoxReceiptsQuery(data.NextAlias());

			if (data.Root == null)
			{
				data.Root = me;
			}
			
			data.Root.InnerJoin(parent).On(parent.BoxID == me.BoxID);

			data.You = parent;
		}			
		
		/// <summary>
		/// Zero to Many
		/// Foreign Key Name - FK_FIN_BOXR_REFERENCE_FIN_BOX
		/// </summary>

		[XmlIgnore]
		public FinBoxReceiptsCollection FinBoxReceiptsCollectionByBoxID
		{
			get
			{
				if(this._FinBoxReceiptsCollectionByBoxID == null)
				{
					this._FinBoxReceiptsCollectionByBoxID = new FinBoxReceiptsCollection();
					this._FinBoxReceiptsCollectionByBoxID.es.Connection.Name = this.es.Connection.Name;
					this.SetPostSave("FinBoxReceiptsCollectionByBoxID", this._FinBoxReceiptsCollectionByBoxID);
				
					if (this.BoxID != null)
					{
						if (!this.es.IsLazyLoadDisabled)
						{
							this._FinBoxReceiptsCollectionByBoxID.Query.Where(this._FinBoxReceiptsCollectionByBoxID.Query.BoxID == this.BoxID);
							this._FinBoxReceiptsCollectionByBoxID.Query.Load();
						}

						// Auto-hookup Foreign Keys
						this._FinBoxReceiptsCollectionByBoxID.fks.Add(FinBoxReceiptsMetadata.ColumnNames.BoxID, this.BoxID);
					}
				}

				return this._FinBoxReceiptsCollectionByBoxID;
			}
			
			set 
			{ 
				if (value != null) throw new Exception("'value' Must be null"); 
			 
				if (this._FinBoxReceiptsCollectionByBoxID != null) 
				{ 
					this.RemovePostSave("FinBoxReceiptsCollectionByBoxID"); 
					this._FinBoxReceiptsCollectionByBoxID = null;
					
				} 
			} 			
		}
			
		
		private FinBoxReceiptsCollection _FinBoxReceiptsCollectionByBoxID;
		#endregion

		#region FinLendBoxCollectionByBoxID - Zero To Many
		
		static public esPrefetchMap Prefetch_FinLendBoxCollectionByBoxID
		{
			get
			{
				esPrefetchMap map = new esPrefetchMap();
				map.PrefetchDelegate = yncTech.BusinessObjects.FinBox.FinLendBoxCollectionByBoxID_Delegate;
				map.PropertyName = "FinLendBoxCollectionByBoxID";
				map.MyColumnName = "BoxID";
				map.ParentColumnName = "BoxID";
				map.IsMultiPartKey = false;
				return map;
			}
		}		
		
		static private void FinLendBoxCollectionByBoxID_Delegate(esPrefetchParameters data)
		{
			FinBoxQuery parent = new FinBoxQuery(data.NextAlias());

			FinLendBoxQuery me = data.You != null ? data.You as FinLendBoxQuery : new FinLendBoxQuery(data.NextAlias());

			if (data.Root == null)
			{
				data.Root = me;
			}
			
			data.Root.InnerJoin(parent).On(parent.BoxID == me.BoxID);

			data.You = parent;
		}			
		
		/// <summary>
		/// Zero to Many
		/// Foreign Key Name - FK_FIN_LEND_REFERENCE_FIN_BOX
		/// </summary>

		[XmlIgnore]
		public FinLendBoxCollection FinLendBoxCollectionByBoxID
		{
			get
			{
				if(this._FinLendBoxCollectionByBoxID == null)
				{
					this._FinLendBoxCollectionByBoxID = new FinLendBoxCollection();
					this._FinLendBoxCollectionByBoxID.es.Connection.Name = this.es.Connection.Name;
					this.SetPostSave("FinLendBoxCollectionByBoxID", this._FinLendBoxCollectionByBoxID);
				
					if (this.BoxID != null)
					{
						if (!this.es.IsLazyLoadDisabled)
						{
							this._FinLendBoxCollectionByBoxID.Query.Where(this._FinLendBoxCollectionByBoxID.Query.BoxID == this.BoxID);
							this._FinLendBoxCollectionByBoxID.Query.Load();
						}

						// Auto-hookup Foreign Keys
						this._FinLendBoxCollectionByBoxID.fks.Add(FinLendBoxMetadata.ColumnNames.BoxID, this.BoxID);
					}
				}

				return this._FinLendBoxCollectionByBoxID;
			}
			
			set 
			{ 
				if (value != null) throw new Exception("'value' Must be null"); 
			 
				if (this._FinLendBoxCollectionByBoxID != null) 
				{ 
					this.RemovePostSave("FinLendBoxCollectionByBoxID"); 
					this._FinLendBoxCollectionByBoxID = null;
					
				} 
			} 			
		}
			
		
		private FinLendBoxCollection _FinLendBoxCollectionByBoxID;
		#endregion

		#region FinShippingBoxesCollectionByBoxID - Zero To Many
		
		static public esPrefetchMap Prefetch_FinShippingBoxesCollectionByBoxID
		{
			get
			{
				esPrefetchMap map = new esPrefetchMap();
				map.PrefetchDelegate = yncTech.BusinessObjects.FinBox.FinShippingBoxesCollectionByBoxID_Delegate;
				map.PropertyName = "FinShippingBoxesCollectionByBoxID";
				map.MyColumnName = "BoxID";
				map.ParentColumnName = "BoxID";
				map.IsMultiPartKey = false;
				return map;
			}
		}		
		
		static private void FinShippingBoxesCollectionByBoxID_Delegate(esPrefetchParameters data)
		{
			FinBoxQuery parent = new FinBoxQuery(data.NextAlias());

			FinShippingBoxesQuery me = data.You != null ? data.You as FinShippingBoxesQuery : new FinShippingBoxesQuery(data.NextAlias());

			if (data.Root == null)
			{
				data.Root = me;
			}
			
			data.Root.InnerJoin(parent).On(parent.BoxID == me.BoxID);

			data.You = parent;
		}			
		
		/// <summary>
		/// Zero to Many
		/// Foreign Key Name - FK_FIN_SHIP_REFERENCE_FIN_BOX
		/// </summary>

		[XmlIgnore]
		public FinShippingBoxesCollection FinShippingBoxesCollectionByBoxID
		{
			get
			{
				if(this._FinShippingBoxesCollectionByBoxID == null)
				{
					this._FinShippingBoxesCollectionByBoxID = new FinShippingBoxesCollection();
					this._FinShippingBoxesCollectionByBoxID.es.Connection.Name = this.es.Connection.Name;
					this.SetPostSave("FinShippingBoxesCollectionByBoxID", this._FinShippingBoxesCollectionByBoxID);
				
					if (this.BoxID != null)
					{
						if (!this.es.IsLazyLoadDisabled)
						{
							this._FinShippingBoxesCollectionByBoxID.Query.Where(this._FinShippingBoxesCollectionByBoxID.Query.BoxID == this.BoxID);
							this._FinShippingBoxesCollectionByBoxID.Query.Load();
						}

						// Auto-hookup Foreign Keys
						this._FinShippingBoxesCollectionByBoxID.fks.Add(FinShippingBoxesMetadata.ColumnNames.BoxID, this.BoxID);
					}
				}

				return this._FinShippingBoxesCollectionByBoxID;
			}
			
			set 
			{ 
				if (value != null) throw new Exception("'value' Must be null"); 
			 
				if (this._FinShippingBoxesCollectionByBoxID != null) 
				{ 
					this.RemovePostSave("FinShippingBoxesCollectionByBoxID"); 
					this._FinShippingBoxesCollectionByBoxID = null;
					
				} 
			} 			
		}
			
		
		private FinShippingBoxesCollection _FinShippingBoxesCollectionByBoxID;
		#endregion

				
		#region UpToBFThirdUnitByBoxLocation - Many To One
		/// <summary>
		/// Many to One
		/// Foreign Key Name - FK_FIN_BOX_REFERENCE_BF_THIRD
		/// </summary>

		[XmlIgnore]
					
		public BFThirdUnit UpToBFThirdUnitByBoxLocation
		{
			get
			{
				if (this.es.IsLazyLoadDisabled) return null;
				
				if(this._UpToBFThirdUnitByBoxLocation == null && BoxLocation != null)
				{
					this._UpToBFThirdUnitByBoxLocation = new BFThirdUnit();
					this._UpToBFThirdUnitByBoxLocation.es.Connection.Name = this.es.Connection.Name;
					this.SetPreSave("UpToBFThirdUnitByBoxLocation", this._UpToBFThirdUnitByBoxLocation);
					this._UpToBFThirdUnitByBoxLocation.Query.Where(this._UpToBFThirdUnitByBoxLocation.Query.ThirdUnitID == this.BoxLocation);
					this._UpToBFThirdUnitByBoxLocation.Query.Load();
				}	
				return this._UpToBFThirdUnitByBoxLocation;
			}
			
			set
			{
				this.RemovePreSave("UpToBFThirdUnitByBoxLocation");
				

				if(value == null)
				{
					this.BoxLocation = null;
					this._UpToBFThirdUnitByBoxLocation = null;
				}
				else
				{
					this.BoxLocation = value.ThirdUnitID;
					this._UpToBFThirdUnitByBoxLocation = value;
					this.SetPreSave("UpToBFThirdUnitByBoxLocation", this._UpToBFThirdUnitByBoxLocation);
				}
				
			}
		}
		#endregion
		

		
		protected override esEntityCollectionBase CreateCollectionForPrefetch(string name)
		{
			esEntityCollectionBase coll = null;

			switch (name)
			{
				case "FinBoxReceiptsCollectionByBoxID":
					coll = this.FinBoxReceiptsCollectionByBoxID;
					break;
				case "FinLendBoxCollectionByBoxID":
					coll = this.FinLendBoxCollectionByBoxID;
					break;
				case "FinShippingBoxesCollectionByBoxID":
					coll = this.FinShippingBoxesCollectionByBoxID;
					break;	
			}

			return coll;
		}		
		/// <summary>
		/// Used internally by the entity's hierarchical properties.
		/// </summary>
		protected override List<esPropertyDescriptor> GetHierarchicalProperties()
		{
			List<esPropertyDescriptor> props = new List<esPropertyDescriptor>();
			
			props.Add(new esPropertyDescriptor(this, "FinBoxReceiptsCollectionByBoxID", typeof(FinBoxReceiptsCollection), new FinBoxReceipts()));
			props.Add(new esPropertyDescriptor(this, "FinLendBoxCollectionByBoxID", typeof(FinLendBoxCollection), new FinLendBox()));
			props.Add(new esPropertyDescriptor(this, "FinShippingBoxesCollectionByBoxID", typeof(FinShippingBoxesCollection), new FinShippingBoxes()));
		
			return props;
		}
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PreSave.
		/// </summary>
		protected override void ApplyPreSaveKeys()
		{
			if(!this.es.IsDeleted && this._UpToBFThirdUnitByBoxLocation != null)
			{
				this.BoxLocation = this._UpToBFThirdUnitByBoxLocation.ThirdUnitID;
			}
		}
		
		/// <summary>
		/// Called by ApplyPostSaveKeys 
		/// </summary>
		/// <param name="coll">The collection to enumerate over</param>
		/// <param name="key">"The column name</param>
		/// <param name="value">The column value</param>
		private void Apply(esEntityCollectionBase coll, string key, object value)
		{
			foreach (esEntity obj in coll)
			{
				if (obj.es.IsAdded)
				{
					obj.SetProperty(key, value);
				}
			}
		}
		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PostSave.
		/// </summary>
		protected override void ApplyPostSaveKeys()
		{
			if(this._FinBoxReceiptsCollectionByBoxID != null)
			{
				Apply(this._FinBoxReceiptsCollectionByBoxID, "BoxID", this.BoxID);
			}
			if(this._FinLendBoxCollectionByBoxID != null)
			{
				Apply(this._FinLendBoxCollectionByBoxID, "BoxID", this.BoxID);
			}
			if(this._FinShippingBoxesCollectionByBoxID != null)
			{
				Apply(this._FinShippingBoxesCollectionByBoxID, "BoxID", this.BoxID);
			}
		}
		
	}
	



	[Serializable]
	public partial class FinBoxMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected FinBoxMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxID, 0, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxID;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxLocation, 1, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxLocation;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxNo, 2, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxNo;
			c.CharacterMaxLength = 20;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.DocumentType, 3, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.DocumentType;
			c.CharacterMaxLength = 20;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.FunctionDept, 4, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.FunctionDept;
			c.CharacterMaxLength = 20;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxYear, 5, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxYear;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxMonth, 6, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxMonth;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxYearEnd, 7, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxYearEnd;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxMonthEnd, 8, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxMonthEnd;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.BoxIndex, 9, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.BoxIndex;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.StorageStatus, 10, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.StorageStatus;
			c.CharacterMaxLength = 20;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.SupplierBoxNo, 11, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.SupplierBoxNo;
			c.CharacterMaxLength = 20;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IsOpenNa, 12, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinBoxMetadata.PropertyNames.IsOpenNa;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.NoSapReceiptCount, 13, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.NoSapReceiptCount;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.CreatedBy, 14, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.CreatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.CreatedDttm, 15, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinBoxMetadata.PropertyNames.CreatedDttm;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.UpdatedBy, 16, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.UpdatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.UpdatedDttm, 17, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinBoxMetadata.PropertyNames.UpdatedDttm;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.VersionNo, 18, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.VersionNo;
			c.NumericPrecision = 10;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.CompanyName, 19, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.CompanyName;
			c.CharacterMaxLength = 30;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.CompanyCode, 20, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.CompanyCode;
			c.CharacterMaxLength = 30;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IsDeleted, 21, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinBoxMetadata.PropertyNames.IsDeleted;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.ThirdUnitCabinId, 22, typeof(System.Guid), esSystemType.Guid);
			c.PropertyName = FinBoxMetadata.PropertyNames.ThirdUnitCabinId;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.ThirdUnitNumberId, 23, typeof(System.Guid), esSystemType.Guid);
			c.PropertyName = FinBoxMetadata.PropertyNames.ThirdUnitNumberId;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IsSap, 24, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinBoxMetadata.PropertyNames.IsSap;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IsHis, 25, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinBoxMetadata.PropertyNames.IsHis;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.NeedStoreYear, 26, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.NeedStoreYear;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IsUpdating, 27, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinBoxMetadata.PropertyNames.IsUpdating;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IndexStart, 28, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.IndexStart;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IndexEnd, 29, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.IndexEnd;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.IndexType, 30, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.IndexType;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.DeleteReason, 31, typeof(System.String), esSystemType.String);
			c.PropertyName = FinBoxMetadata.PropertyNames.DeleteReason;
			c.CharacterMaxLength = 500;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinBoxMetadata.ColumnNames.DeleteReceiptCount, 32, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = FinBoxMetadata.PropertyNames.DeleteReceiptCount;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public FinBoxMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string BoxID = "BoxID";
			 public const string BoxLocation = "BoxLocation";
			 public const string BoxNo = "BoxNo";
			 public const string DocumentType = "DocumentType";
			 public const string FunctionDept = "FunctionDept";
			 public const string BoxYear = "BoxYear";
			 public const string BoxMonth = "BoxMonth";
			 public const string BoxYearEnd = "BoxYearEnd";
			 public const string BoxMonthEnd = "BoxMonthEnd";
			 public const string BoxIndex = "BoxIndex";
			 public const string StorageStatus = "StorageStatus";
			 public const string SupplierBoxNo = "SupplierBoxNo";
			 public const string IsOpenNa = "IsOpen_na";
			 public const string NoSapReceiptCount = "NoSapReceiptCount";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDttm = "CreatedDttm";
			 public const string UpdatedBy = "UpdatedBy";
			 public const string UpdatedDttm = "UpdatedDttm";
			 public const string VersionNo = "VersionNo";
			 public const string CompanyName = "CompanyName";
			 public const string CompanyCode = "CompanyCode";
			 public const string IsDeleted = "IsDeleted";
			 public const string ThirdUnitCabinId = "ThirdUnitCabinId";
			 public const string ThirdUnitNumberId = "ThirdUnitNumberId";
			 public const string IsSap = "IsSap";
			 public const string IsHis = "IsHis";
			 public const string NeedStoreYear = "NeedStoreYear";
			 public const string IsUpdating = "IsUpdating";
			 public const string IndexStart = "IndexStart";
			 public const string IndexEnd = "IndexEnd";
			 public const string IndexType = "IndexType";
			 public const string DeleteReason = "DeleteReason";
			 public const string DeleteReceiptCount = "DeleteReceiptCount";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string BoxID = "BoxID";
			 public const string BoxLocation = "BoxLocation";
			 public const string BoxNo = "BoxNo";
			 public const string DocumentType = "DocumentType";
			 public const string FunctionDept = "FunctionDept";
			 public const string BoxYear = "BoxYear";
			 public const string BoxMonth = "BoxMonth";
			 public const string BoxYearEnd = "BoxYearEnd";
			 public const string BoxMonthEnd = "BoxMonthEnd";
			 public const string BoxIndex = "BoxIndex";
			 public const string StorageStatus = "StorageStatus";
			 public const string SupplierBoxNo = "SupplierBoxNo";
			 public const string IsOpenNa = "IsOpenNa";
			 public const string NoSapReceiptCount = "NoSapReceiptCount";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDttm = "CreatedDttm";
			 public const string UpdatedBy = "UpdatedBy";
			 public const string UpdatedDttm = "UpdatedDttm";
			 public const string VersionNo = "VersionNo";
			 public const string CompanyName = "CompanyName";
			 public const string CompanyCode = "CompanyCode";
			 public const string IsDeleted = "IsDeleted";
			 public const string ThirdUnitCabinId = "ThirdUnitCabinId";
			 public const string ThirdUnitNumberId = "ThirdUnitNumberId";
			 public const string IsSap = "IsSap";
			 public const string IsHis = "IsHis";
			 public const string NeedStoreYear = "NeedStoreYear";
			 public const string IsUpdating = "IsUpdating";
			 public const string IndexStart = "IndexStart";
			 public const string IndexEnd = "IndexEnd";
			 public const string IndexType = "IndexType";
			 public const string DeleteReason = "DeleteReason";
			 public const string DeleteReceiptCount = "DeleteReceiptCount";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(FinBoxMetadata))
			{
				if(FinBoxMetadata.mapDelegates == null)
				{
					FinBoxMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (FinBoxMetadata.meta == null)
				{
					FinBoxMetadata.meta = new FinBoxMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("BoxID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("BoxLocation", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("BoxNo", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("DocumentType", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("FunctionDept", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("BoxYear", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("BoxMonth", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("BoxYearEnd", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("BoxMonthEnd", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("BoxIndex", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("StorageStatus", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("SupplierBoxNo", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("IsOpenNa", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("NoSapReceiptCount", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("CreatedBy", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("CreatedDttm", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("UpdatedBy", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("UpdatedDttm", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("VersionNo", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("CompanyName", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("CompanyCode", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("IsDeleted", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("ThirdUnitCabinId", new esTypeMap("uniqueidentifier", "System.Guid"));
				meta.AddTypeMap("ThirdUnitNumberId", new esTypeMap("uniqueidentifier", "System.Guid"));
				meta.AddTypeMap("IsSap", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsHis", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("NeedStoreYear", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("IsUpdating", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IndexStart", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("IndexEnd", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("IndexType", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("DeleteReason", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("DeleteReceiptCount", new esTypeMap("int", "System.Int32"));			
				
				
				
				meta.Source = "Fin_Box";
				meta.Destination = "Fin_Box";
				
				meta.spInsert = "proc_Fin_BoxInsert";				
				meta.spUpdate = "proc_Fin_BoxUpdate";		
				meta.spDelete = "proc_Fin_BoxDelete";
				meta.spLoadAll = "proc_Fin_BoxLoadAll";
				meta.spLoadByPrimaryKey = "proc_Fin_BoxLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private FinBoxMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
